
window.onload=function(){//当页面加载完执行内容
//传用户名
		var a = document.getElementById('dlu');
		var user = localStorage.getItem("user");
		if(user!=null){
			a.innerHTML = '<span><a href="RegLogin.html" style="color:#aac4bc">'+user+'</a></span>';
		}
//轮播
       flag = 0; 
       obj1 = document.getElementById("listImg"); //获取id为list的值
       obj2 = document.getElementById("btn").getElementsByTagName("li"); //获取图片列表
       obj2[0].style.backgroundColor = "#666666";//默认被选中颜色 
       lbtimer = setInterval("turn();", 6000); //设置定时器
       obj1.onmouseover = function () { //鼠标移入清除定时器
       clearInterval(lbtimer); 
       } 
       obj1.onmouseout = function () { //鼠标移出开启定时器
       lbtimer = setInterval("turn();", 6000); 
      } 
  
       for (var num = 0; num < obj2.length; num++) { //遍历
       obj2[num].onmouseover = function () { //当鼠标移入
       turn(this.innerHTML);//调用turn函数 
       clearInterval(lbtimer); //清除定时器
      } 
       obj2[num].onmouseout = function () { 
       lbtimer = setInterval("turn();", 6000); //开启定时器
    } 
   }  
  } 
      /*封装函数turn */
      function turn(value) { 
      if (value != null) { 
         flag = value - 2; //从第一张开始
       } 
      if (flag < obj2.length - 1){ 
        flag++; 
       }
      else{
        flag = 0; 
      }
      obj1.style.top = flag * (-400) + "px"; //400为图片的高度
      for (var j = 0; j < obj2.length; j++) { //按钮全部为白色
      obj2[j].style.backgroundColor = "#ffffff"; 
      } 
      obj2[flag].style.backgroundColor = "#666666"; //被选中为灰色
};

  